package com.koalac.ironman.util;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.view.LayoutInflater;
import android.view.View;

import com.foot.travel.R;

public abstract class BaseDialogHelper {
	
	protected Context mContext;
	protected Dialog mDialog;
	protected View mContentView;
	
	public BaseDialogHelper(Context context) {
		mContext = context;
		mContentView = LayoutInflater.from(mContext).inflate(
				getLayoutID(), null);
		mDialog = DialogUtils.createCustomDialog(mContext, mContentView);
		mDialog.getWindow().setBackgroundDrawableResource(R.color.transparent);
		init(mContentView);
	}
	/**
	 * 提供给子类的初始方法
	 */
	protected abstract void init(View contentView);
	protected abstract int getLayoutID();
	
	
	public Dialog getDialog() {
		return mDialog;
	}

	public void showDialog() {
		if (mDialog.isShowing()) {
			return;
		}
		mDialog.show();
	}
	
	public void dismissDialog() {
		if (mDialog.isShowing()) {
			mDialog.dismiss();
		}
	}

}
